package com.hee.erp.aop;

import com.alibaba.fastjson.JSON;
import com.hee.erp.annotation.Log;
import com.hee.erp.filter.LoginContextHolder;
import com.hee.erp.modules.entity.SysLog;
import com.hee.erp.modules.service.ISysLogService;
import com.hee.erp.pojo.LoginInfo;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;

@Aspect
@Component
public class LogAspect {

    @Autowired
    ISysLogService sysLogService;

    @AfterReturning("within(com.hee.erp.modules.controller.*) && @annotation(log)")
    public void addLog(JoinPoint joinPoint, Log log){
        LoginInfo loginInfo = LoginContextHolder.get();
        sysLogService.saveLog(joinPoint,log,loginInfo);
    }
}
